<?php
/**
 * Created by PhpStorm.
 * User: root
 * Date: 11/14/18
 * Time: 7:09 PM
 */

namespace caroltc\jenkinsapp\library;


class Facade
{
    private static $config = [];
    /**
     * @param $key
     * @param string $default
     * @return string|int|array
     */
    public static function config($key, $default = '')
    {
        if (empty($config)) {
            $config = require DIR_ROOT . 'config.php';
            static::$config = $config;
        }
        return isset(static::$config[$key]) ? static::$config[$key] : $default;
    }

    /**
     * 是否调试模式(页面直接输出日志)
     * @return bool
     */
    public static function isDebugMode()
    {
        return isset($_COOKIE['DEBUG']) && $_COOKIE['DEBUG'] == 1;
    }

    /**
     * 设置调试的DEBUG_KEY
     */
    public static function setDebugKey()
    {
        $_SESSION['DEBUG_KEY'] =  uniqid(rand(1,100));
    }

    /**
     * 获取调试的DEBUG_KEY
     * @return string
     */
    public static function getDebugKey()
    {
        $data = $_SESSION['DEBUG_KEY'];
        return empty($data) ? 'all' : $data;
    }
}